package com.fph.design;

/**
 * 双重锁校验(线程安全)
 * 锁的⽅式是⽅法级锁的优化，减少了部分获取实例的耗时。
 * 同时这种⽅式也满⾜了懒加载。
 *
 * @ClassName Singleton_05
 * @Description TODO
 * @Author fph
 * @Date 2024-08-06 11:40
 **/
public class Singleton_05 {

    private static Singleton_05 instance;

    private Singleton_05() {
    }

    public static Singleton_05 getInstance() {
        if(null == instance){
            synchronized (Singleton_05.class){
                if(null == instance){
                    instance = new Singleton_05();
                }
            }
        }
        return instance;
    }
}

